import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import vueSetupExtend from 'unplugin-vue-setup-extend-plus/vite'
import cesium from 'vite-plugin-cesium';
import AutoImport from 'unplugin-auto-import/vite'

export default defineConfig({
  plugins: [vue(), vueSetupExtend(),cesium(),
    AutoImport({imports:['vue']})
  ],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, 'src'),
      'public': path.resolve(__dirname, 'public')
    }
  },
  server: {
    cors: true, // 默认启用并允许任何源
    host: '0.0.0.0',
    proxy: {
      '/api/': {
        // target: 'http://192.168.1.130:33333',
        // target: 'http://120.77.79.24:36666',
        // target: 'http://192.168.1.130:36666',
        // target: 'http://192.168.1.253:36666',
        target: 'http://cn.qlmsmart.com',
        changeOrigin: true,
        logLevel: 'debug',
        // rewrite: (path) => path.replace(/^\/api/, '')
        rewrite: (path) => path.replace(/^\/api/, '/api/')
      }
    }
  }
})
